package com.jimmyhsu.activitydemo2;

import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends BaseActivity implements View.OnClickListener {

    private Button mBtnNormal;
    private Button mBtnDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initViews();
        initEvents();
    }

    private void initEvents() {
        mBtnNormal.setOnClickListener(this);
        mBtnDialog.setOnClickListener(this);
    }

    private void initViews() {
        mBtnNormal = (Button) findViewById(R.id.id_btn_normal);
        mBtnDialog = (Button) findViewById(R.id.id_btn_dialog);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.id_btn_normal:
                SecondActivity.startActivity(this);
                break;
            case R.id.id_btn_dialog:
                AlertDialog alertDialog = new AlertDialog.Builder(this)
                        .setTitle("Alert")
                        .setMessage("hahaha")
                        .setPositiveButton("好", null)
                        .create();
                alertDialog.show();
                break;
        }
    }
}
